﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;
using System.Data;

namespace BUS
{
    public class DatBanBUS
    {
        public static List<DatBanDTO> ListDatBan()
        {
            DataTable dt = DatBanDAO.ListDatBan();
            List<DatBanDTO> lstDB= null;
            if (dt != null)
            {
                lstDB = new List<DatBanDTO>();
                foreach (DataRow dr in dt.Rows)
                {
                    DatBanDTO db = new DatBanDTO();
                    db.MaDB = int.Parse(dr["MADATBAN"].ToString());
                    db.TenKH = dr["TENKH"].ToString();
                    db.SDT = dr["SODIENTHOAI"].ToString();
                    db.Soluong=int.Parse(dr["SOLUONG"].ToString());
                    db.Gio = dr["GIO"].ToString();
                    db.Tinhtrang=int.Parse(dr["TINHTRANG"].ToString());
                    db.Ngay = (DateTime)dr["NGAY"];
                    lstDB.Add(db);
                }
            }
            return lstDB;
        }
        public static bool Datban(DatBanDTO db)
        {
            int kt = DatBanDAO.Datban(db);
            if (kt > 0)
                return true;
            return false;
        }

        public static bool Huy(int madb)
        {
            int kt = DatBanDAO.Huy(madb);
            if (kt > 0)
                return true;
            return false;


        }
    }
}
